package com.shujia.MR.sort;

import com.shujia.MR.Writable.WritableReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * 对学生的总分进行排序，并且为倒排
 * 数据源：    1500100001	施笑槐*22*女*文科六班*406
 * 输出（\t分割）   1500100001 施笑槐 22 女 文科六班 406
 */
public class SortDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        job.setJobName("Sort");
        job.setJarByClass(SortDriver.class);

        job.setMapperClass(SortMapper.class);

        job.setMapOutputKeyClass(Student.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(Student.class);
        job.setOutputValueClass(NullWritable.class);

        FileInputFormat.addInputPath(job, new Path("D:\\workspace19\\HadoopCode\\output\\joinOutRes"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\workspace19\\HadoopCode\\output\\sortRes"));

        job.waitForCompletion(true);
    }
}
